﻿using System;
using System.Windows.Forms;

namespace Auxiliary.ExpandedGroupBox
{
    public partial class ExpandedGroupBox : GroupBox
    {
        private bool _isHiden;
        private int _previousHeight=100;

        public ExpandedGroupBox()
        {
            InitializeComponent();

            showButton.Dock = DockStyle.Top;
        }

        public bool IsHiden
        {
            get { return _isHiden; }
            set
            {
                _isHiden = value;
                if (_isHiden)
                {
                    _previousHeight = Height;
                    Height = 40;
                    showButton.Text = "Expand";
                }
                else
                {
                    Height = _previousHeight;
                    showButton.Text = "Hide";
                }
            }
        }

        private void ShowButtonClick(object sender, EventArgs e)
        {
            IsHiden = !IsHiden;
        }
    }
}
